package futbol.tacticas.concursantes.Cascoporro;

import java.awt.*;

/**
 * Created by IntelliJ IDEA.
 * User: Alberto
 * Date: 07-jun-2008
 * Time: 21:49:48
 * To change this template use File | Settings | File Templates.
 */
public class Zona {

    Point tl;
    Point br;
    int rh, rv;
    
    public Zona (int tlx, int tly, int brx, int bry){
        tl = new Point(tlx, tly);
        br = new Point(brx, bry);
    }

    public Zona (int cx, int cy, int r, boolean horizontal){
        if(horizontal){
            rh = r;
            rv = r/2;
        }else{
            rh = r/2;
            rv = r;
        }
        tl = new Point(cx-rh, cy-rv);
        br = new Point(cx+rh, cy+rv);
    }


    public Zona(Point topLeft, Point bottomRight){
        tl = topLeft;
        br = bottomRight;
    }

    public Point getCentro(){
        return new Point((br.x+tl.x)/2, (br.y+tl.y)/2);
    }

    public boolean estaDentro(Point p){
        if(tl.x < p.x && p.x < br.x)
            if(tl.y < p.y && p.y < br.y)
                return true;

        return false;
    }

}
